from socket import *
import sys
import time

serverPort  = 12000
serverSocket = socket(AF_INET, SOCK_DGRAM)
serverPort.bind(('', serverPort))

print(" This is a UDP_Ping_Server!!")

while True:

    print("I'm sending information!!!")

    t = time.localtime()
    t = t.tm_sec%2
    
    if t==0:
        message, addr = serverSocket.recvfrom(1024)
        message = message.decode()
        
        message = message.upper()
        serverSocket.sendto(message, addr)
        print("Send successfully")
    else:
        print("Packet lost")
        
serverSocket.close()

